import java.io.File

/* groovylint-disable-next-line ClassJavadoc */
/* groovylint-disable-next-line ClassJavadoc, ClassName, CompileStatic */
class hello {

    /* groovylint-disable-next-line MethodName, MethodReturnTypeRequired, NoDef */
    static DisplayName() {
        println('This is how methods work in groovy')
        println('This is an example of a simple method')
    }

    static int sum(int a, int b) {
        int c = a + b
        return c
    }

    static void main(String[] args) {
        println('Hello world')

        /* groovylint-disable-next-line NoDef, VariableTypeRequired */
        int count = 0

        /* groovylint-disable-next-line NoDef, VariableTypeRequired */
        def range = 5..10

        println(range)

        /* groovylint-disable-next-line DuplicateNumberLiteral */
        println(range.get(0))

        println('-' * 10)

        DisplayName()

        /* groovylint-disable-next-line DuplicateNumberLiteral, DuplicateStringLiteral */
        println('-' * 10)

        /* groovylint-disable-next-line NoDef, VariableTypeRequired */
        // def c = sum(4, 5)
        println('4 加 5 的值是： ' + sum(4, 5))

        /* groovylint-disable-next-line DuplicateNumberLiteral, DuplicateStringLiteral */
        println('-' * 10)

        /* groovylint-disable-next-line DuplicateNumberLiteral */
        while (count < 10) {
            println(count)
            count++
        }

        /* groovylint-disable-next-line DuplicateNumberLiteral */
        for (int i = 0; i < 5; i++) {
            println(i)
        }

        /* groovylint-disable-next-line JavaIoPackageAccess, NglParseError */
        new File('groovy_basic.md').eachLine {
            line -> println "line : $line"
        }

        /* groovylint-disable-next-line DuplicateNumberLiteral, DuplicateStringLiteral */
        println('\n-\n')

        /* groovylint-disable-next-line DuplicateStringLiteral, JavaIoPackageAccess */
        File file = new File('groovy_basic.md')
        println "The file ${file.absolutePath} has ${file.length()} bytes"
        // file.mkdir() 创建目录
        // file.delete() 删除文件
        //   =======================================
        //   复制文件
        //   def src = new File("E:/Example.txt")
        //   def dst = new File("E:/Example1.txt")
        //   dst << src.text
        //   =======================================
        /* groovylint-disable-next-line UnnecessaryGetter */
        println "File? ${file.isFile()}"
        println file.text

        /* groovylint-disable-next-line DuplicateNumberLiteral, DuplicateStringLiteral */
        println('\n-\n')

        /* groovylint-disable-next-line NoJavaUtilDate */
        Date date = new Date()
        println date.toString()
    }
/* groovylint-disable-next-line NglParseError */
}
